<div class="row" ng-controller="newsListController">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <form name="form" class="form-validation form-horizontal">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">{{new.id?'修改':'添加'}}最近上新</h4>
                </div>
                <div class="modal-body">
                    <!--修改-->
                    <div class="row" >
                        <div class="col-md-12">
                                <div class="form-group character-counter">
                                    <label class="control-label col-md-2">商家</label>

                                    <div class="col-md-10">
                                        <input type="text" class="form-control" placeholder="请输入商家" ng-model="new.business" value="{{new.business}}" maxlength="50" required/>
                                        <label class="character-counter-label-2" ng-bind="(new.business != undefined ? new.business.length : 0)+' / 50'">
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group character-counter">
                                    <label  class="control-label col-md-2">餐品</label>
                                    <div class="col-md-10">
                                        <input type="text" class="form-control" placeholder="请输入餐品" ng-model="new.food" value="{{new.food}}" maxlength="50" required/>
                                        <label class="character-counter-label-2" ng-bind="(new.food != undefined ? new.food.length : 0)+' / 50'">
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group character-counter">
                                    <label  class="control-label col-md-2">价格</label>
                                    <div class="col-md-10">
                                        <input type="price" class="form-control"  placeholder="请输入价格" ng-model="new.price" value="{{new.price}}" maxlength="50" required/>
                                        <label class="character-counter-label-2" ng-bind="(new.price != undefined ? new.price.length : 0)+' / 50'">
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group character-counter">
                                    <label  class="control-label col-md-2">餐品图片URL</label>
                                    <div class="col-md-10">
                                        <input type="text" class="form-control"  placeholder="请输入餐品图片URL" ng-model="new.pictureUrl" value="{{new.pictureUrl}}"  required/>
                                    </div>
                                </div>
                        </div>
                    </div>
                    <!--修改-->
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary"  ng-click="saveNews()" ng-disabled="form.$invalid" data-dismiss="modal">提交</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                </div>
            </div>
                </form>
        </div>
    </div>
    <div class="col-md-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h1 class="panel-title">
                    最近上新列表
                </h1>
            </div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">
                <table class="table table-hover table-cell table-bordered">
                    <thead>
                    <tr>
                        <th></th>
                        <th>商家</th>
                        <th>餐品</th>
                        <th>价格</th>
                        <th>餐品图片URL</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="new in news">
                        <td>{{$index+1}}</td>
                        <td>{{new.business}}</td>
                        <td>{{new.food}}</td>
                        <td>{{new.price}}</td>
                        <td>{{new.pictureUrl}}</td>
                        <td>
                            <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal" ng-click="updateNews(new)">修改
                            </button>
                            <button class="btn btn-primary btn-sm" ng-click="deleteNews(new.id,new.food)">删除
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
                        </div>
                    </div>
            </div>
            <div class="panel-footer">
                <button type="button" class="btn btn-info " data-toggle="modal" data-target="#myModal" ng-click="addNews()">添加最近上新</button>
                <a href="#/welcomePage" class="btn btn-info">返回首页</a>
            </div>
        </div>
    </div>
    <!-- Modal -->

</div>